
import {ajax} from '@/http/api'

var request = function () {
    var self = {};
    /*
       --登录/注册--
    */
    //发送短信验证码
    self.sendSms = function (data, successfn) {
        ajax('/common/api/captcha/mobile', data, false, false, 'POST', successfn);
    };
    //获取图片验证码
    self.getImgCode = function (data, successfn) {
        ajax('/common/api/captcha/image', data, false, false, 'GET', successfn);
    };
    //登录/注册
    self.login = function (data, successfn) {
        ajax('/common/api/auth/login_by_phone/phone', data, false, false, 'POST', successfn);
    };
    //退出登录
    self.logout = function (data, successfn) {
        ajax('/common/api/auth/logout', data, false, false, 'POST', successfn);
    };
    /*
       --首页--
    */
    //分类
    self.getNavList = function (data, successfn) {
        ajax('/_md/lib/api/categoryCount', data, false, false, 'GET', successfn);
    };
    //经典套系列表
    self.getClassicList = function (data, successfn) {
        ajax('/_md/lib/api/data_subjects/home', data, false, false, 'GET', successfn);
    };
    //获取分类数据list
    self.getCategorysList = function (data, successfn) {
        ajax('/_md/lib/api/data_categorys/class/books', data, false, false, 'GET', successfn);
    };
    /*
       --列表list--
    */
    //左侧tree (?type=column):列表   (type=subject):套系专题
    self.getDataCategorys = function (data, successfn) {
        ajax('/_md/lib/api/data_categorys', data, false, false, 'GET', successfn);
    };
    /*
       --搜索--
    */
    //关键词快捷搜索
    self.getQuickSearch = function (data, successfn) { 
        ajax('/_md/lib/api/data_articles/search', data, false, false, 'GET', successfn);
    };
    //高级搜索
    self.getHighSearch = function (data, successfn) { 
        ajax('/_md/lib/api/data_articles/search_advanced', data, false, false, 'POST', successfn);
    };
    /*
       --经典套系--
    */
    //获取套系详情简介
    self.getSerDesc = function (data, successfn) { 
        ajax('/_md/lib/api/data_subjects', data, false, true, 'GET', successfn);
    };
    //获取套系卷册
    self.getSerVolume = function (data, successfn) { 
        ajax('/_md/lib/api/data_categorys/filter/subject', data, false, false, 'GET', successfn);
    };
    //获取套系list数据
    self.getSerList = function (data, successfn) { 
        ajax('/_md/lib/api/data_subjects/class/books', data, false, false, 'GET', successfn);
    };
    /*
       --详情--
    */
    self.getDetails = function (data, successfn) { 
        ajax('/_md/lib/api/data_articles', data, false, true, 'GET', successfn);
    };
    //获取关联详情
    self.getGlDetails = function (data, successfn) { 
        ajax('/_md/lib/api/data_articles', data, false, false, 'GET', successfn);
    };
    self.addCollect = function (data, successfn) { 
        ajax('/_md/lib/api/bookshelf/books', data, false, false, 'POST', successfn);
    };
    /*
       --个人中心--
    */
    //获取个人信息
    self.getUserInfo = function (data, successfn) { 
        ajax('/_md/lib/api/auth/is_login/user', data, false, false, 'GET', successfn);
    };
    //个人信息提交
    self.submitDesc = function (data, successfn) { 
        ajax('/common/api/user/users/detail', data, false, false, 'PUT', successfn);
    };
    //我的收藏
    self.getCollection = function (data, successfn) { 
        ajax('/_md/lib/api/bookshelf/books', data, false, false, 'GET', successfn);
    };
    //我的笔记
    self.getNote = function (data, successfn) { 
        ajax('/_md/lib/api/book_notes', data, false, false, 'GET', successfn);
    };
    //阅读历史
    self.getHistory = function (data, successfn) { 
        ajax('/_md/lib/api/read_list', data, false, false, 'GET', successfn);
    };
    //我的书签
    self.getBookMark = function (data, successfn) { 
        ajax('/_md/lib/api/book_marks', data, false, false, 'GET', successfn);
    };
    //购买记录
    self.getRecord = function (data, successfn) { 
        ajax('/_md/lib/api/home/orders', data, false, false, 'GET', successfn);
    };
    //我的收藏删除
    self.delCollect = function (data, successfn) { 
        ajax('/_md/lib/api/bookshelf/delete', data, false, false, 'POST', successfn);
    };
    //我的笔记删除
    self.delNote = function (data, successfn) { 
        ajax('/_md/lib/api/book_notes/delete', data, false, false, 'POST', successfn);
    };
    //阅读历史删除
    self.delHistory = function (data, successfn) { 
        ajax('/_md/lib/api/read_list/delete', data, false, false, 'POST', successfn);
    };
    return self;
}();

export {
    request
}